﻿CREATE PROCEDURE [acms].[PostTopic_Delete]
	@PostVersionId int, 
	@TopicId int,
	@ConcurencyId rowversion
AS
	if Exists (Select null from PostTopics where PostVersionId = @PostVersionId and TopicId = @TopicId and Deleted = 0) begin
		update PostTopics
		set Deleted = 1
		where PostVersionId = @PostVersionId and TopicId = @TopicId and ConcurencyId = @ConcurencyId
		if @@rowcount = 1
			return 0
		else if @@rowcount = 0
			return -100
		else
			return -300
	end
	else
		return -200
	
	
RETURN 0;